package org.javaboy.listener_demo.event;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

@Component
public class MyEventPublisher implements ApplicationEventPublisherAware {
    private static ApplicationEventPublisher publisher;
    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        publisher = applicationEventPublisher;
    }

    public static void publishEvent(Object event) {
        publisher.publishEvent(event);
    }
    public static void publishEvent(ApplicationEvent event) {
        publisher.publishEvent(event);
    }
}
